﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace WpfApp3_Grid
{
    /// <summary>
    /// Window3.xaml 的交互逻辑
    /// </summary>
    public partial class Window3 : Window
    {
        public Window3()
        {
            InitializeComponent();
        }

        private void lMode_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            SelectionMode mode = SelectionMode.Single;
            switch((sender as ListBox).SelectedIndex)
            {
                case 0:
                    mode = SelectionMode.Single;
                    break;
                case 1:
                    mode = SelectionMode.Multiple;
                    break;
                case 2:
                    mode = SelectionMode.Extended;
                    break;
            }
            this.lHobby.SelectionMode = mode;
        }

        private void lHobby_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            tResult.Text = string.Empty;

            StringBuilder sb = new StringBuilder();
            foreach(ListBoxItem item in (sender as ListBox).SelectedItems)
            {
                sb.AppendLine(item.Content.ToString());
            }

            tResult.Text = sb.ToString();
        }
    }
}
